package com.rock.code.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;




/**
 * <p>
 *  写成文件公共类
 * <p>
 * @author  chenhl modify zhangli 2019-2-16
 * @version 1.0
 */
public class WriteKPI {


	WriteFile  wf = new WriteFile();


	/**
	 * @param regionCode 区域编码
	 * @param kpi_id     kpi
	 * @param kpi_value  kpi的值
	 * @return 记录kpi信息的7元组
	 */
	public TblSevenStruc writeKpi(String regionCode,String kpi_id,String kpi_value){
		TblSevenStruc tblSevenStruc = new TblSevenStruc();
		tblSevenStruc.setUnit_id("unit_Id");
		tblSevenStruc.setRegion_code(regionCode);
		tblSevenStruc.setKpi_id(kpi_id);
		tblSevenStruc.setData_time("xxx");
		tblSevenStruc.setCll_time("noUse");//WriteFile文件将重写这个值
		tblSevenStruc.setBusi_code("xxx");
		tblSevenStruc.setKpi_values(String.valueOf(kpi_value));
		return tblSevenStruc;
	}


	/**
	 * writeKPI 将7元组写到文件中
	 * @param kpi_value, kpi值
	 * @param kpi_id
	 */
	public void writeSingleKPI(long kpi_value,String kpi_id,String unit_id,String data_time,String swap_path,String cll_region){
		Vector  	vKpi =  new Vector();//保存一组kpi的向量
		TblSevenStruc ss = new TblSevenStruc();
		ss.setUnit_id(unit_id);
		ss.setRegion_code(cll_region);
		ss.setKpi_id(kpi_id);
		ss.setData_time(data_time);
		ss.setCll_time("noUse");//WriteFile文件将重写这个值
		ss.setBusi_code("xxx");
		ss.setKpi_values(String.valueOf(kpi_value));
		vKpi.add(ss);
		wf.writeSevenStrucFile(swap_path,vKpi);

	}

	public Vector<TblSevenStruc> getVECTOR() {
		return VECTOR;
	}

	private final Vector<TblSevenStruc> VECTOR= new Vector<TblSevenStruc>();
	/**
	 * writeKPI 将7元组写到文件中
	 * @param kpi_value, kpi值
	 * @param kpi_id
	 */
	public void writeKPItoList(String kpi_value,String kpi_id,String unit_id,String data_time,String cll_region){
		TblSevenStruc ss = new TblSevenStruc();
		ss.setUnit_id(unit_id);
		ss.setRegion_code(cll_region);
		ss.setKpi_id(kpi_id);
		ss.setData_time(data_time);
		ss.setCll_time("xxx");//WriteFile文件将重写这个值
		ss.setBusi_code("xxx");
		ss.setKpi_values(kpi_value);
		VECTOR.add(ss);
	}


	/***
	 * @Author zhangli
	 * @Description //TODO 所有的kpi统一写到文件中
	 * @Date 14:03 2019/2/16
	 * @Param []
	 * @return void
	 **/
	public void writeALLKPI(String swap_path){

		wf.writeSevenStrucFile(swap_path,VECTOR);
	}

	public final static String getNowTime() {
		SimpleDateFormat formatter1
				= new  SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
		return  formatter1.format(new Date());
	}

	synchronized private String getCurrTime() {
		Date date = new Date();
		String sCurrTime = "" + date.getTime();
		return sCurrTime;
	}

}


